package com.cssl.controller;

import cn.hutool.core.util.ObjectUtil;
import com.cssl.domain.dto.DtsSearchHistoryDto;
import com.cssl.service.DtsSearchHistoryService;
import com.cssl.util.InfoCode;
import com.cssl.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/userHistory")
public class DtsSearchHistoryController {
    @Autowired
    private DtsSearchHistoryService dtsSearchHistoryService;

    @PostMapping("/listHistory")
    public Result getHistoryList(@RequestBody DtsSearchHistoryDto dtsSearchHistoryDto) {
        Map historyList = dtsSearchHistoryService.getHistoryList(dtsSearchHistoryDto);
        if (ObjectUtil.isEmpty(historyList.get("list"))) {
            return Result.result(InfoCode.QUERY_EMPTY, InfoCode.MESSAGE_QUERY_EMPTY, null, System.currentTimeMillis());
        }
        return Result.result(InfoCode.OK, InfoCode.MESSAGE_OK, historyList, System.currentTimeMillis());

    }
}
